/*
* Copyright (c) 2010 Michael Collins
*
* This file is part of TerraFirma.
*
* TerraFirma is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TerraFirma is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TerraFirma.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONTEXT_H
#define CONTEXT_H

/**
    Context is a singleton class that defines the current operating environment of the application.
    Contains references to the opengl context, the input context, a bunch of info about the
    computer, whatever. None of this should change throughout normal operation of the program.

    Due to thread safety issues, most of this is read-only through normal runtime routines
**/

#include <SFML/Window.hpp>
#include "world.h"
#include "host.h"
#include "configuration.h"
#include "config.h"

class context
{
private:
    context() {}
    ~context() {}
    //Prevent copy construction and assignment
    context(const context &);
    context& operator=(const context&);

public:
    static context& Instance()
    {
        static context con;
        return con;
    }

    sf::Window main_window;
    bool is_server; //True when this host is acting as a server processing game events
    bool is_client; //True when this host is interfacing with a player directly
    bool singleplayer; //True when the localhost is the only host in the game (we don't need to run a network queue)
    uint8_t hostid; //The hostid that uniquely identifies localhost. Should be 0 if localhost is server
    uint8_t playerid;
    game::World world;
    game::Configuration config;

    engine::segmented_pool<engine::host> hosts;
};

#endif // CONTEXT_H
